package com.baozhun.mall.common.adapter

import android.view.View
import com.alibaba.android.arouter.launcher.ARouter
import com.baozhun.mall.common.BR
import com.baozhun.mall.common.R
import com.baozhun.mall.common.arouter.RoutePath
import com.baozhun.mall.common.base.BaseListAdapter
import com.baozhun.mall.common.databinding.ItemSubClassifyBinding
import com.baozhun.mall.common.model.bean.ActivityInfoBean
import com.baozhun.mall.common.model.bean.ClassifyInfo
import com.baozhun.mall.common.util.Constants
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder

/**
 * @Title：
 * @Description：
 * @Author：xing.luo
 * @Since：2022/12/19
 * @Version：1.0.0
 */
class SubClassifyListAdapter(data: MutableList<ClassifyInfo>?) :
    BaseListAdapter<ClassifyInfo, ItemSubClassifyBinding>(R.layout.item_sub_classify, data) {

    override fun convert(holder: BaseDataBindingHolder<ItemSubClassifyBinding>, item: ClassifyInfo) {
        holder.dataBinding?.setVariable(BR.model, item.name)
        holder.dataBinding?.root?.setOnClickListener(View.OnClickListener {
            ARouter.getInstance().build(RoutePath.Home.ACTIVITY_DETAIL)
                .withSerializable(Constants.Common.BUNDLE_NAME, ActivityInfoBean(item.id,  Constants.Common.TYPE_CLASSIFY))
                .withString(Constants.Common.TITLE, item.name)
                .navigation()
        })
    }
}